Skip to main content

Class: PeerToPeerManager

The PeerToPeerManager is responsible for handling peer-to-peer data exchanges between users, specifically for initiating and managing proof requests. It allows one user (the initiator) to send a proof request to another user (the receiver), requesting specific information such as verified credentials or self-attested data. The manager facilitates various types of proof requests, including self-attested information, SD-JWT data, and verified email, ensuring that data exchanges occur securely and according to specified formats.

Method: sendProofRequest

The sendProofRequest() method is used to initiate a peer-to-peer proof request between two users. This method allows one user (the initiator) to request specific information or credentials from another user (the receiver). Depending on the request type, it can ask for self-attested data, SD-JWT data, or a verified email.

  • Purpose: The method allows the initiator to send a proof request to the receiver, asking them to provide specific data or credentials. The proof request is customized based on the type of data required, such as self-attested information, SD-JWT data, or verified email.

  • Parameters:

    • initiatorAlias: string — The alias of the user initiating the request.
    • receiverAlias: string — The alias of the user receiving the request.
    • type: PeerToPeerProofRequestTypes — The type of proof request. It can be one of the following:
      • self-attested: Requests for self-attested data.
      • sd-jwt: Requests for SD-JWT data.
      • verified-email: Requests for verified email data.
  • Returns: Promise<OperationResult> — Resolves to an OperationResult object indicating whether the proof request was successfully sent. If successful, it returns true; otherwise, it returns false with an error message.

Usage Example

export enum PeerToPeerProofRequestTypes {
SelfAttested = 'self-attested',
SdJwt = 'sd-jwt',
VerifiedEmail = 'verified-email'
}

const initiatorAlias = 'userInitiator';
const receiverAlias = 'userReceiver';
const type = PeerToPeerProofRequestTypes.VerifiedEmail;

// Send a proof request for verified email
const result = await agent.peerToPeerManager.sendProofRequest(initiatorAlias, receiverAlias, type);

if (result.isSuccessful) {
console.log("Proof request sent successfully.");
} else {
console.error("Failed to send proof request:", result.error);
}

Example Output (Success)

{
"isSuccessful": true
}

Common Use Cases

  • Requesting Verified Data: When one user wants to verify another user's email or self-attested information through peer-to-peer data sharing.
  • Data Exchange: Facilitating secure peer-to-peer proof requests to exchange sensitive data like verified credentials.
X

Graph View